//
//  TLS_WelcomeVC.m
//  Travel_World
//
//  Created by lanou on 15/10/12.
//  Copyright © 2015年 TLS. All rights reserved.
//

#import "TLS_WelcomeVC.h"

@interface TLS_WelcomeVC ()<UIScrollViewDelegate>
@property (nonatomic, retain) UIScrollView *picScrollView;
@property (nonatomic, retain) UIPageControl *myPageControl;
@end

@implementation TLS_WelcomeVC
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:0.171 green:0.565 blue:0.969 alpha:1.000];
    
    self.picScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT+113)];
    self.picScrollView.backgroundColor = [UIColor colorWithRed:0.171 green:0.565 blue:0.969 alpha:1.000];
    self.picScrollView.contentSize = CGSizeMake(WIDTH*3, HEIGHT+113);
    self.picScrollView.pagingEnabled = YES;
    self.picScrollView.delegate = self;
    self.picScrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.picScrollView];
    
    for (NSInteger i = 0; i < 3; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i*WIDTH, 0, WIDTH, HEIGHT+113)];
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld.png",i+1]];
        [self.picScrollView addSubview:imageView];
        
        if (i == 2) {
            UIButton *welcomeButton = [UIButton buttonWithType:UIButtonTypeCustom];
            [self.picScrollView addSubview:welcomeButton];
            welcomeButton.frame = CGRectMake(WIDTH/2-80*WID + WIDTH*2, HEIGHT-60*HEI, 160*WID, 40);
            welcomeButton.layer.borderColor = [UIColor colorWithRed:0.171 green:0.565 blue:0.969 alpha:1.000].CGColor;
            welcomeButton.backgroundColor = [UIColor colorWithRed:0.582 green:0.780 blue:0.979 alpha:1.000];
            welcomeButton.layer.borderWidth = 0.4;
            welcomeButton.layer.cornerRadius = 20;
            welcomeButton.titleLabel.font = [UIFont boldSystemFontOfSize:25];
            [welcomeButton setTitle:@"立即启程" forState:UIControlStateNormal];
            [welcomeButton setTitleColor:GBCOLOR forState:UIControlStateNormal];
            [welcomeButton addTarget:self action:@selector(welcome:) forControlEvents:UIControlEventTouchUpInside];
        }
    }
    self.myPageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(WIDTH/2-75*WID, HEIGHT, 150*WID, 40)];
    self.myPageControl.numberOfPages = 3;
    self.myPageControl.pageIndicatorTintColor = [UIColor grayColor];
    [self.view addSubview:self.myPageControl];
}
- (BOOL)prefersStatusBarHidden{
    return YES;
}
- (void)welcome:(UIButton *)button{
    self.block();
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    self.myPageControl.currentPage = scrollView.contentOffset.x/WIDTH;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
